package com.adv.ems.manager.impl;

import com.adv.ems.db.mapper.CircuitDiagramNodeMeterRelationMapper;
import com.adv.ems.db.entity.CircuitDiagramNodeMeterRelationDO;
import com.adv.ems.manager.CircuitDiagramNodeMeterRelationManager;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class CircuitDiagramNodeMeterRelationManagerImpl extends BaseManagerImpl<CircuitDiagramNodeMeterRelationMapper, CircuitDiagramNodeMeterRelationDO> implements CircuitDiagramNodeMeterRelationManager {
    @Override
    public List<Long> getDeviceIds(Collection<Long> nodeIds) {
        return list()
                .stream()
                .filter(r -> nodeIds.contains(r.getDiagramNodeId()))
                .map(CircuitDiagramNodeMeterRelationDO :: getMeterId)
                .collect(Collectors.toList());
    }

    @Override
    public void saveData(CircuitDiagramNodeMeterRelationDO relation) {
        save(relation);
    }

    @Override
    public void deleteById(Long id) {
        removeById(id);
    }
}
